package stack;

import java.util.Arrays;

public class STackand {
private static final int MAX_LENGTH = 10;
public Object []data=new Object[MAX_LENGTH];
public int top=0;
public void push(Object k){
	if (top>=data.length) {
		data =Arrays.copyOf(data, data.length*2);
		}
	for (int i = top; i >0; i--) {
		data[i]=data[i-1];
	}
		data[0]=k;
		
		
		top++;
	}
	
	public Object peek(){
		return data[top-1];
	}
	public Object pop(){
		if (top<=0) {
			System.out.println("");
		}
		top=top-1;
		return data[top];
	}
	public int size(){
		return top;
		
	}
	public void clear(){
		Arrays.fill(data,null);
		top=0;
	}
}

